package com.vote.vs.service.impl;

import com.vote.vs.dao.UserMapper;
import com.vote.vs.entity.User;
import com.vote.vs.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class UserServiceImpl implements UserService {
    @Autowired
    private UserMapper userMapper;

    @Override
    public Boolean login(String username, String password) {
        if (userMapper.selectByusername(username) == null) {
            return false;
        }
        boolean b = userMapper.selectByusername(username).getVuPassword().equals(password);
        if (b) {
            return true;
        } else {
            return false;
        }
    }

    @Override
    public Boolean regist(User user) {
        //如果这个user数据库中还没有相同的username 便可以注册
        if (userMapper.selectByusername(user.getVuUserName()) == null) {
            userMapper.insert(user);
            return true;
        } else {
            return false;
        }

    }
}
